package com.synnex.mobile.servier.core.actRecord.dao.impl;

import com.synnex.mobile.generic.dao.impl.GenericHibernateDaoImpl;
import com.synnex.mobile.servier.core.actRecord.dao.ActRecordDao;
import com.synnex.mobile.servier.core.actRecord.dao.FolderDao;
import com.synnex.mobile.servier.core.actRecord.dto.ActivityRecord;
import com.synnex.mobile.servier.core.actRecord.dto.Folder;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: kerryf
 * Date: 13-8-5
 * To change this template use File | Settings | File Templates.
 */
public class FolderDaoImpl extends GenericHibernateDaoImpl<Folder, Integer> implements FolderDao {


    public List<Folder> ListFolder(String category) {
        Criteria c = this.getSession().createCriteria(Folder.class);
        if(category!=null && !category.equals("")){
            c.add(Restrictions.eq("category",category));
        }
        c.addOrder(Order.asc("seq"));
        return c.list();
    }

    public void addFolder(Folder folder) {
        this.getSession().save(folder) ;
    }

    public void editFolder(Folder folder) {
        this.update(folder);
    }

    public Folder getFolderById(Integer id) {
        return this.get(id);
    }

    public void deleteFolderById(Integer id) {
            super.delete(super.get(id));
    }
}
